<!DOCTYPE html >
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>权限管理</title>
    <span th:replace="common/link"></span>
    <script type="text/javascript">
        $(function () {
            //JQuery == $
            $(".loadpermission_btn").click(function () {
                $.messager.confirm("友情提示","是否需要重新加载权限!权限加载可能需要几分钟",function() {
                    $.ajax({
                        url: $(".loadpermission_btn").data("href"),
                        type: "POST",
                        dataType: 'json',
                        success: function (result) {
                            if (result.code == 1000) {
                                $.messager.alert("友情提示", "重新加载成功");
                                location.href = "/permission/list";
                            }
                            if(result.code == 1004){
                                $.messager.alert("友情提示",result.data);
                            }
                        }
                    });
                });
            });

            $(".btn-delete").click(function(){
                $.messager.confirm("友情提示","是否确定删除",function(){
                    jQuery.ajax({
                        url: $(".btn-delete").data("href"),
                        type: "POST",
                        dataType: 'json',
                        success: function (result) {
                            if(result.code == 1000){
                                $.messager.alert("友情提示","删除成功");
                                location.href="/permission/list";

                            }
                            if(result.code == 1004){
                                $.messager.alert("友情提示",result.data);
                            }
                        }
                    });
                });
            });
        })
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <div th:replace="common/navbar::navBar"></div>
    <!--菜单回显-->
    <div th:replace="common/menu::menuBar"></div>
    <div class="content-wrapper">
        <section class="content-header">
            <h1>权限管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <!--高级查询--->
                <form class="form-inline" id="searchForm" action="/permission/list" method="get">
                    <input type="hidden" name="pageIndex" id="currentPage" value="1">
                    <a href="javascript:;;" class="btn btn-success btn-input loadpermission_btn" style="margin: 10px" data-href="/permission/reload">
                        <span class="glyphicon glyphicon-refresh"></span> 重新加载
                    </a>
                </form>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>权限名称</th>
                            <th>权限表达式</th>
                            <th>操作</th>
                        </tr>
                        <!--权限列表-->
                        <tr th:each="permission:${page.records}">
                            <td th:text="${permission.id}">1</td>
                            <td th:text="${permission.name}">查询学生</td>
                            <td th:text="${permission.expression}">/student/query</td>
                            <td>
                                <a th:data-href="@{/permission/delete(id=${permission.id})}"  href="javascript:;;" class="btn btn-danger btn-xs btn-delete">
                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                </a>
                            </td>
                        </tr>

                    </table>
                    <!--分页-->
                    <div th:replace="common/pagePlus::paginationPage"></div>
                </div>
            </div>
        </section>
    </div>
    <div th:replace="common/footer::footerPage"></div>
</div>
</body>
</html>
